/*
 * @Author: WuFeng <763467339@qq.com>
 * @Date: 2022-03-22 12:12:49
 * @LastEditTime: 2024-05-22 00:13:11
 * @LastEditors: WuFeng <763467339@qq.com>
 * @Description: {{{=it.newOptions.moduleTitle || ""}}}管理接口
 * @FilePath: \vue-code-design\templates\vue3ElementPlus\DrawerDemo\api\{{{=it.newOptions.MODULE_VALUE}}}.js
 * @Copyright 版权声明
 */

import request from '@/utils/request'

/**
 * @description 获取列表
 */
export function getList(params) {
  return request({
    url: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.list !== 'undefined' && typeof apiConfig.list.url !== 'undefined' && apiConfig.list.url !== '') {
        return apiConfig.list.url;
      }
      return `/${it.newOptions.MODULE_VALUE}/list`;
    })(it)}}}',
    method: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.list !== 'undefined' && typeof apiConfig.list.method !== 'undefined' && apiConfig.list.method !== '') {
        return apiConfig.list.method;
      }
      return `get`;
    })(it)}}}',
    {{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.list !== 'undefined' && typeof apiConfig.list.method !== 'undefined' && apiConfig.list.method !== '' && apiConfig.list.method === 'post') {
        return `data: params`;
      }
      return `params`;
    })(it)}}}
  })
}

/**
 * @description 获取详情
 */
export function getDetail(params) {
  return request({
    url: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.detail !== 'undefined' && typeof apiConfig.detail.url !== 'undefined' && apiConfig.detail.url !== '') {
        return apiConfig.detail.url;
      }
      return `/${it.newOptions.MODULE_VALUE}/detail`;
    })(it)}}}',
    method: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.detail !== 'undefined' && typeof apiConfig.detail.method !== 'undefined' && apiConfig.detail.method !== '') {
        return apiConfig.detail.method;
      }
      return `get`;
    })(it)}}}',
    {{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.detail !== 'undefined' && typeof apiConfig.detail.method !== 'undefined' && apiConfig.detail.method !== '' && apiConfig.detail.method === 'post') {
        return `data: params`;
      }
      return `params`;
    })(it)}}}
  })
}

/**
 * @description 添加保存
 * @param {*} params
 */
export function addSave(params) {
  const data = params
  return request({
    url: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.add !== 'undefined' && typeof apiConfig.add.url !== 'undefined' && apiConfig.add.url !== '') {
        return apiConfig.add.url;
      }
      return `/${it.newOptions.MODULE_VALUE}/add`;
    })(it)}}}',
    method: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.add !== 'undefined' && typeof apiConfig.add.method !== 'undefined' && apiConfig.add.method !== '') {
        return apiConfig.add.method;
      }
      return `post`;
    })(it)}}}',
    {{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.add !== 'undefined' && typeof apiConfig.add.method !== 'undefined' && apiConfig.add.method !== '' && apiConfig.add.method === 'get') {
        return `params: data`;
      }
      return `data`;
    })(it)}}}
  })
}

/**
 * @description 编辑保存
 * @param {*} params
 */
export function updateSave(params) {
  const data = params
  return request({
    url: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.update !== 'undefined' && typeof apiConfig.update.url !== 'undefined' && apiConfig.update.url !== '') {
        return apiConfig.update.url;
      }
      return `/${it.newOptions.MODULE_VALUE}/update`;
    })(it)}}}',
    method: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.update !== 'undefined' && typeof apiConfig.update.method !== 'undefined' && apiConfig.update.method !== '') {
        return apiConfig.update.method;
      }
      return `post`;
    })(it)}}}',
    {{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.update !== 'undefined' && typeof apiConfig.update.method !== 'undefined' && apiConfig.update.method !== '' && apiConfig.update.method === 'get') {
        return `params: data`;
      }
      return `data`;
    })(it)}}}
  })
}

/**
 * @description 删除保存
 * @param {*} params
 */
export function deleteSave(params) {
  const data = params
  return request({
    url: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.delete !== 'undefined' && typeof apiConfig.delete.url !== 'undefined' && apiConfig.delete.url !== '') {
        return apiConfig.delete.url;
      }
      return `/${it.newOptions.MODULE_VALUE}/delete`;
    })(it)}}}',
    method: '{{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.delete !== 'undefined' && typeof apiConfig.delete.method !== 'undefined' && apiConfig.delete.method !== '') {
        return apiConfig.delete.method;
      }
      return `post`;
    })(it)}}}',
    {{{=(function(it) {
      const apiConfig = it.newOptions.apiConfig || {};
      if (typeof apiConfig.delete !== 'undefined' && typeof apiConfig.delete.method !== 'undefined' && apiConfig.delete.method !== '' && apiConfig.delete.method === 'get') {
        return `params: data`;
      }
      return `data`;
    })(it)}}}
  })
}

export default {}
